
public class QuickSort {

	
	public static void main(String[] args) {
		
		
		
		
		
		int[] a = {22, 11, 13, 15, 12, 14, 20, 19};
		int i=-1;
		int t;
		while(a[++i]!=0){
			System.out.println(a[i]);
		}
		
//		
//		qsort(a,0,a.length-1);
//		
//		for(int t:a)
//			System.out.println(t);
	}
	
	
	
	
	
	static void qsort(int[] array, int i, int j){
		if(j<=i) return;
		
		int pivotindex = findpivot(array, i, j);
		swap(array, pivotindex, j);
		int k = partition(array, i-1, j, array[j]);
		swap(array, k, j);
		qsort(array, i, k-1);
		qsort(array, k+1, j);
	}

	
	
	
	
	private static int findpivot(int[] array, int i, int j) {
		return i;
	}

	private static void swap(int[] array, int i, int j) {
		int temp = array[i];
		array[i] = array[j];
		array[j] = temp;
	}

	private static int partition(int[] array, int l, int r, int pivot) {
		do{
			//while(array[++l] < pivot);
			while((l!=r) && (array[++l] < pivot));
			while((r!=0) && (array[--r] > pivot));
			swap(array, l ,r);
		}while(l < r);
		swap(array, l ,r);
		return l;
	}
}
